<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="id"
        width="200">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="200">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="200">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮件"
        width="200">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="200">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <!--分页插件-->
    <el-pagination
      align="right"
      :page-size="pageSize"
      :pager-count="7"
      :current-page="currentPage"
      layout="prev, pager, next"
      :total="totals"
      @current-change="gotoPage">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      currentPage:1,
      pageSize: 5,
      totals:0,
      tableData:[]
    }
  },
  methods:{
    getUserList() {
      // 调用后端接口 获取用户数据
      let arr = {"currentPage":this.currentPage,"pageSize":this.pageSize}
      this.$http.post("/user/list",arr)
        .then(result => {
          // 调用后端 后端返回的数据就在这里
          this.tableData = result.data.data;
          this.totals = result.data.totals;
        })
        .catch(result => {
          alert(result)
          alert("大哥你网不行吧")
        })
    },
    gotoPage(curr) {
      this.currentPage = curr;
      this.getUserList();
    }
  },
  mounted() {
    this.getUserList();
  }

}
</script>


